// 文章相关的请求

import { request } from "@/utils/main.js"

// 获取频道列表
export const getChannelsList = () => {
  return request({
      url:"/channels",
      method: "GET"
  })
}

// 新增文章
export const postArticle = (data) => {
  return request({
      url: "/mp/articles?draft=false",
      method:"POST",
      data
  })
}

// 获取文章列表
export const getArticlesList = (params) => {
  return request({
      url: "/mp/articles",
      method: "GET",
      params
  })
}

// 根据文章id删除文章
export const deleteArticleById = (id) => {
  return request({
      url: `/mp/articles/${id}`,
      method: "DELETE",
  })
}

// 根据文章id获取文章
export const getArticleById = (id) => {
  return request({
      url: `/mp/articles/${id}`,
      method: "GET"
  })
}

/**
 * 根据文章id更新文章
 * @param data
 * @returns {*}
 */
export const updateArticleById = (data) => {
  return request({
      url: `/mp/articles/${data.id}?draft=false`,
      method: "PUT",
      data
  })
}